package com.smartcommunity.entity.facelib.sensenets2;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@ApiModel(description = "人脸特征提取请求参数模型。")
@Data
public class SenseNets2FaceDetect {

    @ApiModelProperty(value = "人脸图片集合", name = "imgs")
    List<SenseNets2FaceParamImg> imgs;

    // 后台特征提取请求失败重试的次数上限，默认不重试。
    @ApiModelProperty(value = "后台特征提取请求失败重试的次数上限，默认0不重试", name = "retry")
    transient int retry = 0;

    public SenseNets2FaceDetect() {
    }

    public SenseNets2FaceDetect(List<SenseNets2FaceParamImg> imgs, int retry) {
        this.imgs = imgs;
        this.retry=retry;
    }

    public static SenseNets2FaceDetect createInstance(String imgUri, int retry) {
        return createInstance(Lists.newArrayList(imgUri),0);
    }

    public static SenseNets2FaceDetect createInstance(List<String> urls, int retry) {
        return new SenseNets2FaceDetect(urls.stream()
                .map(url -> new SenseNets2FaceParamImg(new SenseNets2FaceParamImgData(url)))
                .collect(Collectors.toList()),retry);
    }

}
